//
//  SRSettingClockViewController.m
//  SportRing
//
//  Created by Elwin on 14-11-5.
//  Copyright (c) 2014年 HotOne. All rights reserved.
//

#import "SRSettingClockViewController.h"
#import "UIColor+LG.h"
#import "SRSettingClockView.h"
#import "SRAlarmService.h"

@interface SRSettingClockViewController ()<SRSettingClockViewDelegate>


@property (nonatomic, strong)SRSilenceClockTableViewCellModel *orginClockModel;
@property (strong, nonatomic) IBOutlet UIView *btnBgview;


@end

@implementation SRSettingClockViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    _btnBgview.layer.borderColor = [UIColor lightGrayColor].CGColor;
    [self addRightStringButton:@"保存"];
    [self addLeftStringButton:@"取消"];
    
    _srSettingClockView.clockModel = _clockModel;
    UIView *view = [[UIView alloc] initWithFrame:_srSettingClockView.frame];
    view.backgroundColor = [UIColor grayColor];
    view.alpha = 0.3;
    [_srSettingClockView insertSubview:view atIndex:0];
}

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    [self hideTabbar];
    self.navigationController.navigationBarHidden = NO;
}

-(void)onRightButtonPressed
{
    [SRAlarmService updateAlarmToDevice:[SRSilenceClockTableViewCellModel toSRAlarm:_clockModel]];
    [_srSettingClockView removeFromSuperview];
    [self.view removeFromSuperview];
    [self removeFromParentViewController];
}

- (void)onLeftButtonPressed
{
    [_srSettingClockView removeFromSuperview];
    [self.view removeFromSuperview];
    [self removeFromParentViewController];
}

- (void)changedClockModel:(SRSilenceClockTableViewCellModel *)clockModel orginColckModel:(SRSilenceClockTableViewCellModel *)orginClockModel
{
    self.clockModel = clockModel; //修改后的闹钟
    
    self.orginClockModel = orginClockModel; //没有修改的闹钟
}


@end
